package temp;

import org.junit.Test;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

/**
 * @author tiny
 * @date 2021/9/28 16:18
 * @Description:
 */
public class FileUtils {

    public static void main(String[] args) {
        new FileUtils().getNames();
    }

    @Test
    public void getNames()  {
//        String prefix = "/mile-account-api/";
        File file = new File("D:\\IdeaProjects\\mile-account\\mile-account-api\\src\\main\\java\\com\\milecn\\account\\api\\service");
        FileWriter fw = null;
        try{
             fw = new FileWriter("D:\\task\\paths.txt");
            for (File f : file.listFiles()) {
                if(f.isFile() && f.getName().endsWith("ApiService.java") ){
//                System.out.println(f.getName());
//                    String path = new StringBuilder(prefix).append(f.getName().substring(0, 1).toLowerCase()).append(f.getName().substring(1,f.getName().indexOf("ApiService.java"))).toString();
                    String path = new StringBuilder(f.getName().substring(0, 1)).append(f.getName().substring(1,f.getName().indexOf("ApiService.java"))).toString();
                    fw.write(path);
                    fw.write("\n");
                    fw.flush();
                }
            }
        }catch (IOException ex){

        }finally {
            try{ if(fw!=null) fw.close(); } catch (IOException ex){}
        }

    }
}
